import type { BaseEnum } from "@/enums/base";

/**
 * 物资订单类型枚举
 * 用于标识不同的物资订单类型
 */
export const OrderType = {
  /**
   * 其它订单
   */
  Other: {
    code: "Other",
    name: "其它订单",
    description: "通用的其他类型订单"
  },

  /**
   * 任务订单
   */
  WorkOrder: {
    code: "WorkOrder",
    name: "任务订单",
    description: "基于工作任务的订单"
  },
  
  /**
   * 借用订单
   */
  Borrow: {
    code: "Borrow",
    name: "借用订单",
    description: "物资借用类型的订单"
  },
} as const;

/**
 * 根据code获取枚举
 * @param code
 * @returns 枚举值或null
 */
export function matchCode(code: string): (typeof OrderType)[keyof typeof OrderType] | null {
  return (
    Object.values(OrderType).find((item) => item.code === code) || null
  );
}

/**
 * 获取所有物资订单类型选项
 * @returns 物资订单类型数组
 */
export function getOrderTypeOptions(): (typeof OrderType)[keyof typeof OrderType][] {
  return Object.values(OrderType);
}
